package com.hopu.service.impl;

import com.hopu.domain.export.ExportC;
import com.hopu.domain.packing.PackingListC;
import com.hopu.domain.packing.PackingListCExample;
import com.hopu.mapper.export.ExportCMapper;
import com.hopu.mapper.packing.PackingListCMapper;
import com.hopu.service.PackingListCService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class PackingListCServiceImpl implements PackingListCService {

    @Autowired
    PackingListCMapper packingListCMapper;

    @Autowired
    ExportCMapper exportCMapper;

    @Override
    public List<PackingListC> selectByExample() {
        PackingListCExample example = new PackingListCExample();
        return packingListCMapper.selectByExample(example);
    }

    @Override
    public void delete(String[] ids) {
        packingListCMapper.delete(ids);
    }

    @Override
    public void state(Map<String, Object> map) {
        packingListCMapper.state(map);
    }

    @Override
    public PackingListC selectById(String packingListId) {
        return packingListCMapper.selectById(packingListId);
    }

    @Override
    public Object getDivDataCreate(String[] exportIds) {
        StringBuffer sBuf = new StringBuffer();
        for(int i=0;i<exportIds.length;i++){
            ExportC exportC = exportCMapper.selectByPrimaryKey(exportIds[i]);
            sBuf.append("<input type=\"checkbox\" name=\"exportIds\" checked value=\"").append(exportIds[i]).append("|").append(exportC.getCustomerContract()).append("\" class=\"input\"/>");
            sBuf.append(exportC.getCustomerContract()).append("&nbsp;&nbsp;");
        }
        return sBuf.toString();
    }
}
